//
//  ContactsUtil.m
//  iphone.mobileoa
//
//  Created by 李亚春 on 13-5-30.
//  Copyright (c) 2013年 Epoint. All rights reserved.
//

#import "ContactsUtil.h"
#import "RIButtonItem.h"
#import "UIAlertView+Blocks.h"

@implementation ContactsUtil

+(void)call:(NSString *)tag :(NSString *)number
{
    
    
    if (![number isEqualToString:@""]) {
        RIButtonItem *okItem = [RIButtonItem item];
        okItem.label = @"拨打";
        okItem.action = ^
        {
            NSString *numFormat = [NSString stringWithFormat:@"tel://%@",number];
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:numFormat]];
        };
        
        RIButtonItem *msgItem = [RIButtonItem item];
        msgItem.label = @"短信";
        msgItem.action = ^
        {
            NSString *numFormat = [NSString stringWithFormat:@"sms://%@",number];
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:numFormat]];
        };
        
        RIButtonItem *cancelItem = [RIButtonItem item];
        cancelItem.label = @"取消";
        cancelItem.action = ^
        {
        };
        
        
        UIAlertView *alter = [[UIAlertView alloc]initWithTitle:tag message:number cancelButtonItem:cancelItem otherButtonItems:okItem,msgItem,nil];
        [alter show];
        [alter release];
    }
}

+(void)showAlertDetail:(NSString *)tagname :(NSString *)detail
{
    if (detail.length==0) {
        return;
    }
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:tagname
                                                   message:detail
                                                  delegate:nil
                                         cancelButtonTitle:@"关闭"
                                         otherButtonTitles:nil];
    [alert show];
    [alert release];
}

@end
